<template>
  <div class="news-detail">
    <myhander titleName="新闻详情"></myhander>
    <div>
      <h1 class="news-title">{{detailList.title}}</h1>
      <p class="news-info">
        <span>发表时间：{{detailList.add_time | fmtTime}}</span>
        <span>浏览：{{detailList.click}}</span>
        <span>分类：教育</span>
      </p>
    </div>
    <div class="news-content" v-html="detailList.content"></div>
    <comment :id="$route.params.id"></comment>
  </div>
</template>
<script>
// 引入组件
import myhander from '@/components/myhander'
import comment from '@/components/comment'
import {getNewsDetail} from '@/api'
export default {
  data () {
    return {
      id: this.$route.params.id,
      detailList: []
    }
  },
  components: {
    myhander,
    comment
  },
  created () {
    this.initDetail()
  },
  methods: {
    initDetail () {
      getNewsDetail(this.id)
        .then(res => {
          // console.log(res)
          this.detailList = res.message[0]
        })
    }
  }
}
</script>
<style lang="scss" scoped>
  .news-detail {
  padding: 40px 0 0 0;
  .news-title {
    font-size: 14px;
    font-weight: bold;
  }
  .news-info {
    font-size: 12px;
    color: #26a2ff;
    display: flex;
    justify-content: space-between;
  }
  .news-content {
    font-size: 12px;
  }
}
</style>
